//webProtectClass.h : declares the interface of CWebProtectClass
//Author: Peng Chong
//Date  : June/05/2009
//
#ifndef _WEB_PROTECT_CLASS_H_
#define _WEB_PROTECT_CLASS_H_

#include "resource.h"
#include <vector>

/////////////////////////////////////////////////////////////////////
//CWebProtectClass
class ATL_NO_VTABLE CWebProtectClass:
    public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CWebProtectClass, &CLSID_WebProtectClass>,
	public IObjectWithSiteImpl<CWebProtectClass>,
	public IDispatchImpl<IWebProtect, &IID_IWebProtect, &LIBID_WebProtectLib>
{
public:
	CWebProtectClass();

	~CWebProtectClass();

	DECLARE_REGISTRY_RESOURCEID(IDR_REGISTRY1)

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	BEGIN_COM_MAP(CWebProtectClass)
		COM_INTERFACE_ENTRY(IWebProtect)
		COM_INTERFACE_ENTRY(IDispatch)
   		COM_INTERFACE_ENTRY_IMPL(IObjectWithSite)
	END_COM_MAP()

public:
	//The handler before navigating event is fired
	bool Event_BeforeNavigate2_Handler(LPOLESTR url,LONG Flags,LPOLESTR TargetFrameName,PUCHAR PostData,LONG PostDataSize,LPOLESTR Headers,bool Cancel);
	//Routines that this module must implement SetSite and Invoke
	STDMETHOD(SetSite)(IUnknown *pUnkSite);
	STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags,
                     DISPPARAMS * pdispparams, VARIANT * pvarResult,
                     EXCEPINFO * pexcepinfo, UINT * puArgErr);

private:
	//Routine that tries to match the sensitive data
	bool MatchSensitiveData_Handler();

private:
	HRESULT ManageConnectionPoint(BOOL bAdvice); //Manage the connection point
	DWORD m_dwConnectionID;					//The connection cookie
	CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> m_pWebBrowser; 
	std::vector< CComQIPtr<IHTMLInputElement,&IID_IHTMLInputElement> > m_listInputText; //The list to store input boxes on the page
	//std::vector< CComQIPtr<IHTMLFormElement,&IID_IHTMLFormElement> > m_listForm;
	BOOL m_bCheckForm; //The flag that determines whether there is form or not

};
#endif //_WEB_PROTECT_CLASS_H_